package com.huawei.appgallery.appcomment.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSViewProxy;
import com.huawei.appgallery.foundation.ui.css.RenderListener;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import o.bcg.b;
import o.cdo;

public class CommentLabelTextView extends TextView implements RenderListener {
    public CommentLabelTextView(Context context) {
        super(context);
    }

    public CommentLabelTextView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public CommentLabelTextView(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public boolean onRenderReady(CSSViewProxy cSSViewProxy) {
        CSSRule rule = cSSViewProxy.getRule();
        if (rule.getStyleDeclaration() == null) {
            return false;
        }
        CSSValue propertyValue = rule.getStyleDeclaration().getPropertyValue(CSSPropertyName.FONT_COLOR);
        if (propertyValue == null || !(propertyValue instanceof CSSMonoColor)) {
            return false;
        }
        int color = ((CSSMonoColor) propertyValue).getColor();
        Drawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setCornerRadius((float) cdo.ˏ(getContext(), 2));
        gradientDrawable.setStroke(getContext().getResources().getDimensionPixelSize(b.ॱ), color);
        setBackground(gradientDrawable);
        return true;
    }
}
